import { createRouter, createWebHistory } from 'vue-router'
import Login from '../views/Login.vue'
import Home from '../views/Home.vue'
import PersonalExpenses from '../views/PersonalExpenses.vue'

const routes = [
	{
		path: '/',
		component: Login
	},
	{
		path: '/home',
		component: Home,
		redirect: '/home/ReportRepairStudentReport',
		beforeEnter:(to,from,next)=>{
			if(window.sessionStorage.getItem('loginUser')!=null)
				next()
			else{
				alert("请先登录")
				router.push('/')
			}
		},
		children:[
		{
			path: 'ReportRepairStudentReport',
			component: () => import('../views/ReportRepairStudentReport.vue')
		},{
			path: 'ReportRepair',
			component: () => import('../views/ReportRepair.vue')
		},{
			path: 'DisciplinaryManagement',
			component: () => import('../views/DisciplinaryManagement.vue')
		},{
			path: 'DormitoryManagement',
			component: () => import('../views/DormitoryManagement.vue')
		},{
			path: 'NoticeOfViolation',
			component: () => import('../views/NoticeOfViolation.vue')
		},{
			path: 'SanitaryCommons',
			component: () => import('../views/SanitaryCommons.vue')
		},{
			path: 'SanitaryConditions',
			component: () => import('../views/SanitaryConditions.vue')
		},{
			path: 'PersonalExpenses',
			component: PersonalExpenses
		},{
			path: 'Charge',
			component: () => import('../views/Charge.vue')
		},
		{
			path: 'StudentApply',
			component: () => import('../views/StudentApply.vue')
		},{
			path: 'Student',
			component: () => import('../views/Student.vue')
		},{
			path: 'NoticeOfViolation',
			component: () => import('../views/NoticeOfViolation.vue')
		},
	]
  }, 
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})



export default router
